package com.flick.order.services;

import com.flick.order.dao.OrderDao;
import com.flick.po.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {

    @Autowired
    OrderDao dao;

    public List<Order> list(){
        return dao.findAll();
    }

    public Page<Order> page(Integer page, Integer size){
        Pageable pageable = PageRequest.of(page-1,size);
        return dao.findAll(pageable);
    }

    public List<Order> save(List<Order> list){
        return dao.saveAll(list);
    }
}
